package com.yc.book;

import com.google.gson.Gson;
import com.yc.book.dao.BookDao;
import com.yc.book.util.Utils;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.Map;

@WebServlet(name = "QueryBookPageServlet", value = "/queryPage.s")
public class QueryBookPageServlet extends HttpServlet {
    private BookDao dao = new BookDao();


    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String spage = request.getParameter("page");
        String ssize = request.getParameter("size");
        String name = request.getParameter("name");
        String date1 = request.getParameter("date1");
        String date2 = request.getParameter("date2");

        int ipage = Integer.parseInt(spage);
        int isize = Integer.parseInt(ssize);
        Map<String, Object> page = dao.queryPage(name, date1, date2, ipage, isize);
        Utils.writeJson(page, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
